function [c , vx , ax , all] = fepstrum_30ms_w_10ms_over(s, fs)

%xxx = szInFileName;

mkdir('features_test')
block_length = 480; % dlzka bloku FT
%n=block_length;

p = 24;           % pocet filtrov
t = 30e-3;             % casovy usek 100ms
faktor = 40;      % faktor pre podvzorkovanie
M = 40;           % pocet bodov u moving average filtra
N = 60;        %
%FP = 0.01;
%TC = 9;
Emat = Ematica;
%Emat(:, 14:120) = [];
%Emat = Emat';



files = 1;%dir(xxx);

for i = 1:numel(files) % vsetky nahravky
   % i
    %filename = files(i).name;
    %[s,fs] = readsph(['/' filename]);
    %[s,fs] = wavread(xxx);
    
    %s = filter([1 -0.97], 1, s);

    x = melbankm(p,block_length,fs); % melovska banka filtrov
    xx = full(x);
    n2 = 1+floor(block_length/2);

    numb_samp = fs*t;            % pocet vzoriek na 1 ramec
    n=numb_samp;
    nn = n/3;
    numb_fr = 1+((length(s)-numb_samp)/nn);      % pocet ramcov (nezaokruhleny) 
    samp_fr = ((ceil(numb_fr))*nn);    % pocet vzoriek v jednom ramci
    numb_zeros = abs(samp_fr - length(s));          % pocet nul, ktorymi treba rozsirit vektor
    s_ext = wextend('1','zpd',s,numb_zeros, 'r'); % rozsireny vektor s tak, aby nedoslo k strate informacii pri ramcovani
    W = window(@rectwin, numb_samp);  % oknova funkcia
    F = enframe(s_ext, numb_samp,n/3);    % matica, do ktorej je naramcovany signal s_ext
    F2 = F';
    l = 1+floor((length(s_ext)-numb_samp)/nn);
    dl = floor(l); % pocet ramcov

    clear mel_recording windowed mel_mat
    
    mel_full = [];
    rec_fep = [];
    mel_mat = [];
    abs_mat_all = [];
    log_mat_all = [];
    filt_mat_all = [];
    down_mat_all = [];
    dct_mat_all = [];
    
    for j = 1:dl % vsetky ramce
        segment = F2(:,j);
        windowed = W.*segment; %oknovanie
        fourier = (rfft(windowed));

        clear mel_vec ifft_mat abs_mat
        ifft_mat = [];
        abs_mat = [];
        log_mat = [];
        filt_mat = [];
        down_mat = [];
        dct_mat = [];
        

        

        for k = 1:p % vsetky filtre v banke
            mel_vec = xx(k,:)'.*fourier(1:n2); % vektor mel. koeficientov (frekvencii) pre jeden ramec (rozmer 1x801)
            ifft_vec = irfft(mel_vec); % vektor po ifft (jedno pasmo)
            ifft_mat = [ifft_mat ifft_vec]; % kumulacia tychto vektorov do matice (jeden ramec) 1600x24
            abs_vec = abs(ifft_vec);
            abs_mat = [abs_mat abs_vec];
            log_vec = log(abs_vec.^2);
            log_mat = [log_mat log_vec];
            % moving average filtracia pre jeden kanal
            for m = 1:block_length-M
                filt(m) = sum(log_vec(m:(m+M)))/M;
            end
            filt_mat = [filt_mat; filt]; % uloz koeficienty do vektora - 1 kanal
            down_vec = downsample(filt, faktor); % podvzorkovanie pre jeden kanal
            down_mat = [down_mat; down_vec];
            dct_vec = dct(down_vec);
            dct_vec = dct_vec(1:5);
%            dct_vec = [dct_vec(:,1); dct_vec(:,2); dct_vec(:,3)];
            dct_mat = [dct_mat; dct_vec];
        end
            mel_mat = [mel_mat ifft_mat']; % matica celej nahravky po melovskej analyze a ifft dekomponovana do 24 pasiem
            abs_mat_all = [abs_mat_all abs_mat'];
            log_mat_all = [log_mat_all log_mat'];
            filt_mat_all = [filt_mat_all filt_mat];
            down_mat_all = [down_mat_all down_mat];
            dct_mat = reshape(dct_mat', 1, 120)';
            dct_mat_all = [dct_mat_all dct_mat];
    end
            % PCA transformacia
 %           a = reshape (dct_mat', 1, 120);
 %           a = a';
 %           mi = mean(dct_mat_all,2); 
 %           m(24:1) = m;
         % mi = [mi mi mi mi];
 %           [row col] = size(dct_mat_all);
 %           mi = repmat(mi, 1, col);
 %           sig = dct_mat_all - mi; %centrovanie
 %           c = (sig*sig')/(N-1); %kovariancia
 %           c = (a*a')/(N-1);
 %           [vec val] = pcacov(c); %PCA transformacia
 
 
 % dct_obratene_all  = [];
 %for b = 1:514   
 %     dct_obratit = dct_mat_all(:,b);
 %     dct_obratit=dct_obratit';
 %     dct_obratene = fliplr(dct_obratit);
 %     dct_obratene=dct_obratene';
 %     dct_obratene_all = [dct_obratene_all dct_obratene];
 % end
 
            Emat = Emat(:,1:13);
            fep = Emat'*dct_mat_all;
            %fep(14:row, :) = [];
            for g = 1 : 13
            fep(g, : ) = fep(g, : ) - mean(fep(g, : ));
            end
end

c = -(fep);
%DCT = Emat * dct_mat_all; 

c=c';

nf=size(c,1);
nc=13;

  vf=(4:-1:-4)/60;
  af=(1:-1:-1)/2;
  ww=ones(5,1);
  cx=[c(ww,:); c; c(nf*ww,:)];
  vx=reshape(filter(vf,1,cx(:)),nf+10,nc);
  vx(1:8,:)=[];
  ax=reshape(filter(af,1,vx(:)),nf+2,nc);
  ax(1:2,:)=[];
  vx([1 nf+2],:)=[];  
  all=[c vx ax];
  
  c=c';
  ax=ax';
  vx=vx';
  all=all';
  
end

